package com.hurl.library.spider;

public class SpiderConfig {
	
	public static final String HTTP_METHOD_GET = "get";
	public static final String HTTP_METHOD_POST = "post";
	
	private String responseEncoding;
	private String httpMethod = HTTP_METHOD_GET;
	private UrlPattern urlPattern;
	private boolean allowMultiThread = true;
	private int requestIntervalInMillis=200;
	private UrlFilter urlFilter;
	
	/**
	 * 响应的编码格式，如果没有值，则系统会自动判断。
	 * @return
	 */
	public String getResponseEncoding(){
		return this.responseEncoding;
	}
	public void setResponseEncoding(String encoding){
		this.responseEncoding=encoding;
	}
	
	/**
	 * 返回请求方法，只允许返回“get”或“post”
	 * @return 只能是 get 或 post 两种，否则会报错
	 */
	public String getHttpMethod(){
		return this.httpMethod;
	}
	public void setHttpMethod(String method){
		this.httpMethod=method;
	}
	
	/**
	 * 返回网址模版
	 * @return
	 */
	public UrlPattern getUrlPattern(){
		return this.urlPattern;
	}
	public void setUrlPattern(UrlPattern pattern){
		this.urlPattern=pattern;
	}
	
	/**
	 * 如果允许使用多线程下载，返回true；否则返回false
	 * @return
	 */
	public boolean isAllowMultiThread(){
		return this.allowMultiThread;
	}
	public void setAllowMultiThread(boolean allowMultiThread){
		this.allowMultiThread=allowMultiThread;
	}
	
	/**
	 * 返回发送采集数据请求的时间间隔，单位为毫秒。
	 * @return
	 */
	public int getRequestIntervalInMillis(){
		return this.requestIntervalInMillis;
	}
	public void setRequestIntervalInMillis(int interval){
		this.requestIntervalInMillis=interval;
	}
	
	/**
	 * 设置请求地址过滤器。
	 * @param filter
	 */
	public void setUrlFilter(UrlFilter filter){
		this.urlFilter=filter;
	}
	public UrlFilter getUrlFilter(){
		return this.urlFilter;
	}
}
